//
//  MainViewController.swift
//  weibo
//
//  Created by imac on 16/8/5.
//  Copyright © 2016年 gongyujie. All rights reserved.
//

import UIKit

class MainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
       
         addChildViewController("Home", title: "首页", imageName: "tabbar_home")
         addChildViewController("Message", title: "消息", imageName: "tabbar_message_center")
         addChildViewController("Discover", title: "发现", imageName: "tabbar_discover")
         addChildViewController("Profiles", title: "我", imageName: "tabbar_home")
        
        
        
    }
    
    //添加子视图控制器
    func addChildViewController(sbName: String, title: String, imageName: String){
        
        let sb = UIStoryboard(name: sbName, bundle: nil)
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
        nav.topViewController?.navigationItem.title = "title"
        nav.topViewController?.tabBarItem.title = "title"
        nav.topViewController?.tabBarItem.image = UIImage(named: "imageName")
        
        nav.topViewController?.tabBarItem.selectedImage = UIImage(named: "tabbar_home_selected")
        
        self.addChildViewController(nav)
        
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
